﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>@ViewBag.Title</title>
    <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/modernizr-1.7.min.js")" type="text/javascript"></script>
    <script type="text/javascript">

        var application = {}
        application.viewModel = {
            extend: function (childViewModel) {

                var viewModelBase = function () {

                    var self = this;

                    self.onInit = undefined;
                    self.onDestroy = undefined;

                    self.init = function () {
                        self.onInit.apply(self, arguments);
                    }

                    self.destroy = function () {
                        self.onDestroy();
                    }

                }

                var returnFunction = function () {



                    var parent = new viewModelBase();
                    var child = new childViewModel();
                    var extended = $.extend(parent, child);
                    extended.init.apply(extended, arguments);
                    return extended;
                }
                return returnFunction;
            }
        }

//        var viewModelBase = function () {

//            var self = this;

//            self.onInit = function () { alert('init'); }
//            self.onDestroy = function () { alert('destroy'); }

//            self.init = function () {
//                self.onInit.apply(self,arguments);
//            }

//            self.destroy = function () {
//                self.onDestroy();
//            }

//        }

        var customVM = application.viewModel.extend(function () {

            var self = this;

            /*


            */
            self.onInit = function (name) { self.name = name; alert(self.name); }

            /*
                Destroy
            */
        });

        var m = new customVM("sanjay");

        //var m = new viewModelBase();
        //m.init();

    </script>

</head>
<body>
    <div class="page">
        <header>
            <div id="title">
                <h1>My MVC Application</h1>
            </div>
            <div id="logindisplay">
                @Html.Partial("_LogOnPartial")
            </div>
            <nav>
                <ul id="menu">
                    <li>@Html.ActionLink("Home", "Index", "Home")</li>
                    <li>@Html.ActionLink("About", "About", "Home")</li>
                </ul>
            </nav>
        </header>
        <section id="main">
            @RenderBody()
        </section>
        <footer>
        </footer>
    </div>
</body>
</html>
